4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
22 * @ingroup SpecialPage
26 * SpecialShortpages extends QueryPage. It is used to return the shortest
27 * pages in the database.
28 * @ingroup SpecialPage
30 class ShortPagesPage
extends QueryPage
{
37 * This query is indexed as of 1.5
39 function isExpensive() {
43 function isSyndicated() {
48 global $wgContentNamespaces;
50 $dbr = wfGetDB( DB_SLAVE
);
51 $page = $dbr->tableName( 'page' );
52 $name = $dbr->addQuotes( $this->getName() );
54 $forceindex = $dbr->useIndexClause("page_len");
56 if ($wgContentNamespaces)
57 $nsclause = "page_namespace IN (" . $dbr->makeList($wgContentNamespaces) . ")";
59 $nsclause = "page_namespace = " . NS_MAIN
;
62 "SELECT $name as type,
63 page_namespace as namespace,
66 FROM $page $forceindex
67 WHERE $nsclause AND page_is_redirect=0";
70 function preprocessResults( $db, $res ) {
71 # There's no point doing a batch check if we aren't caching results;
72 # the page must exist for it to have been pulled out of the table
73 if( $this->isCached() ) {
74 $batch = new LinkBatch();
75 while( $row = $db->fetchObject( $res ) )
76 $batch->add( $row->namespace, $row->title
);
78 if( $db->numRows( $res ) > 0 )
79 $db->dataSeek( $res, 0 );
83 function sortDescending() {
87 function formatResult( $skin, $result ) {
88 global $wgLang, $wgContLang;
89 $dm = $wgContLang->getDirMark();
91 $title = Title
::makeTitleSafe( $result->namespace, $result->title
);
93 return '<!-- Invalid title ' . htmlspecialchars( "{$result->namespace}:{$result->title}" ). '-->';
95 $hlink = $skin->linkKnown(
99 array( 'action' => 'history' )
101 $plink = $this->isCached()
102 ?
$skin->link( $title )
103 : $skin->linkKnown( $title );
104 $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( htmlspecialchars( $result->value
) ) );
106 return $title->exists()
107 ?
"({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
108 : "<s>({$hlink}) {$dm}{$plink} {$dm}[{$size}]</s>";
115 function wfSpecialShortpages() {
116 list( $limit, $offset ) = wfCheckLimits();
118 $spp = new ShortPagesPage();
120 return $spp->doQuery( $offset, $limit );